<?php

/*

  Action – Duration	$2

  +1 Card; +1 Action
  Set aside a card from your hand face down. At the start of your next turn, put it into your hand.

 */

class Haven extends Card implements iAction, iKingdom, iDuration, iSeaside {

    public function __construct() {
        parent::__construct("Haven", 2);
        $this->duration = 1;
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+1 Action",
            "Set aside a card from your hand face down. At the start of your next turn, put it into your hand.");
    }
    
    public function play(Game $game, $isRealCard) {
        $drawed_cards = $game->drawCards(1);
        $game->addActions(1);
         ScreenDisplay::addScreenMessage($game, true, "get +1 action  and draw " . nicePrint($drawed_cards), "gets +1 action and  draws " . sizeof($drawed_cards) . " cards");


        $playHand = $game->getPlayHand();
        if (sizeof($playHand) > 0) {
			$playHand = getUniqueCards($playHand);
			if (sizeof($playHand) > 1) {
				$output = MySocket::GetUserReply($game, Input_ChooseOne, $playHand, 1, 1, null, "Choose card to set aside with Haven");
				$card_name = $output[0];
			}
			else {
				$card_name = $playHand[0];
			}
            $card = $game->moveCardFromPileToPile($card_name, PlayHand, HavenPile);
            ScreenDisplay::addScreenMessage($game, true, "set to Haven " . nicePrint($card), "sets to Haven " . sizeof($card) . " cards");
        }
		else {
			ScreenDisplay::addScreenMessage($game, true, "set to Haven nothing", "sets to Haven nothing");
		}

        $game->pushCardToDurationAffects($this, 1, $isRealCard);
        $game->cardActionFinished();
        return true;
    }

    public function cleanup(Game $game) {
        $game->moveCardFromPileToPile($this, PlayArea, DurationPileCards);
    }

    public function startTurn(Game $game, $quantity) {
        $haven_cards = $game->PutCardsFromHavenDeckToHand();
        ScreenDisplay::addScreenMessage($game, true, "get ".nicePrint($haven_cards). " from Haven", "gets ".sizeof($haven_cards)." cards from Haven");
        if ($quantity > 0)
            return RETURN_DURATION_TO_DISCARD;
        else
            return DELETE_VIRTUAL_DURATION_CARD;
    }

}

?>